package com.feihao.demoDate;

import jdk.dynalink.linker.support.SimpleLinkRequest;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo01Date {
    public static void main(String[] args) throws ParseException {
        Date  date = new Date();
        System.out.println(date);
        int day = date.getDay();
        System.out.println(day);

        Date date1 = new Date(360000L);
        System.out.println(date1);


        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss:SSS");
        String format = simpleDateFormat.format(date);
        System.out.println(format);


        Date parse = simpleDateFormat.parse("2021-03-23-20:06:39:475");
        System.out.println(parse);

        System.out.println("============================");

        Date date222 = new Date();
        System.out.println(date222);//Wed Mar 24 21:19:56 CST 2021

        Date date2 = new Date(1620888000000L);
        System.out.println(date2);

        //格式化date日期
        String format1 = simpleDateFormat.format(date2);

        System.out.println(format1);

        String time = "1998-06-18";

        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");

        //解析。
        Date d = simpleDateFormat1.parse(time);
        long time1 = d.getTime();
        System.out.println(time1);
        System.out.println(d);

        //getTime();  获取毫秒值：
//        long time = date2.getTime();
        System.out.println(time);

    }
}
